package com.lagou.service.impI;

import com.lagou.dao.IUserDao;
import com.lagou.dao.impI.UserDaoImpI;
import com.lagou.service.IUserService;
import com.lagou.utils.BeanFactory;

/**
 * @Author wsl
 * @Date 2021/11/6 23:13
 * @Project_Name jdbc_spring
 */
public class UserServiceImpI implements IUserService {

    public void save() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        //调用dao层方法，传统方式：存在编译期依赖：重耦合
        //IUserDao userDao = new UserDaoImpI();

        //反射
        //IUserDao userDao = (IUserDao) Class.forName("com.lagou.dao.impI.UserDaoImpI").newInstance();

        //调用bean工厂中自定义的getBean方法，获取map集合中的值
        IUserDao userDao = (IUserDao) BeanFactory.getBean("userDao");

        //调用方法
        userDao.save();
    }
}
